﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

namespace BlueLotus7
{
    partial class Validator
    {
        public static bool IsCharPinCode(string codeString, int length)
        {
            return IsCharPinCode(codeString, length, length);
        }
        public static bool IsCharPinCode(string codeString, int minLength, int maxLength)
        {
            if (codeString != null)
            {
                codeString = codeString.ToUpper();
                Regex reg = new Regex("^[0-9A-Z]{" + minLength.ToString() + "," + maxLength.ToString() + "}$");
                if (reg.IsMatch(codeString))
                    return true;
            }
            return false;
        }

        public static bool IsHexPinCode(string codeString, int length)
        {
            return IsHexPinCode(codeString, length, length);
        }
        public static bool IsHexPinCode(string codeString, int minLength, int maxLength)
        {
            if (codeString != null)
            {
                codeString = codeString.ToUpper();
                Regex reg = new Regex("^[0-9A-F]{" + minLength.ToString() + "," + maxLength.ToString() + "}$");
                if (reg.IsMatch(codeString))
                    return true;
            }
            return false;
        }

        public static bool IsGuid(string guid)
        {
            if (guid != null)
            {
                Regex regex = new Regex("^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$");
                if (regex.IsMatch(guid.ToUpper()))
                    return true;
            }
            return false;
        }
    }
}
